import logging

from _testclinic import keywords

from core.keywords import Keywords
from utils.step_logger import step_logger


class AssertKeyword(Keywords):

    @step_logger
    def assert_url(self,step):
        assert step["data"] in self.driver.current_url,logging.info("❌❌❌❌❌url断言失败")
        logging.info("url断言成功")

    @step_logger
    def assert_title(self,step):
        assert step["data"] in self.driver.title,logging.info(f"❌❌❌❌❌{step["data"]}断言失败")
        logging.info("title断言成功")

    @step_logger
    def assert_alert_text(self,step):
        assert step["data"] in self.driver.switch_to.alert.text,logging.info("❌❌❌❌❌text断言失败")
        logging.info("text断言成功")

    @step_logger
    def assert_text(self,step):
        element=self.find(step)
        assert step["data"] in element.text,logging.info("❌❌❌❌❌text断言失败")
        logging.info("text断言成功")

    @step_logger
    def assert_element_exist(self,step):
        element=self.find(step)
        assert element,logging.info("❌❌❌❌❌element断言失败")
        logging.info("element断言成功")
